package sk.tuke.constraintbuilder.editor;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;

import sk.tuke.constraintbuilder.model.Constraint;
import sk.tuke.constraintbuilder.model.Model;
import sk.tuke.constraintbuilder.views.ConstraintEditorView;

public class ConstraintEditor  extends EditorPart{
	
	public static final String ID = "sk.tuke.constraintbuilder.editor.constrainteditor";
	
	//Core
	private MultiPageEditor parent;
	private EditorInput editorInput;
	
	//MVC
	private ConstraintEditorController controller;
	private ConstraintEditorView view;
	
	public ConstraintEditor(MultiPageEditor parent) {
		this.parent=parent;
	}

	@Override
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
		if (!(input instanceof EditorInput)) {
			throw new RuntimeException("Wrong input");
		}	
		this.editorInput = (EditorInput) input;
		setSite(site);
		setInput(input);
		parent.setTitleName("Constraint Editor");
		setPartName("Constraint Editor");
	}
	
	@Override
	public void createPartControl(Composite parent) {
		controller = new ConstraintEditorController(this);
		view = new ConstraintEditorView(parent, controller);
		controller.setView(view);
	}

	public EditorInput getEditorInput() {
		return editorInput;
	}

	public MultiPageEditor getParent() {
		return parent;
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doSaveAs() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean isDirty() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isSaveAsAllowed() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub
		
	}
}
